package com.czxy.demo01;

import cn.itcast.servlet.BaseServlet;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import java.io.IOException;

@WebServlet("/showServlet")
public class showServlet  extends BaseServlet {

    public void  m01() throws IOException {
        Cookie  ck=new Cookie("lastVisitTime","124");
        getResponse().addCookie(ck);
        getResponse().getWriter().write("cookie添加完毕了");



    }

    public String  a02() throws IOException {
        String username = getRequest().getParameter("username");
        String password = getRequest().getParameter("password");

        Cookie ck1=new Cookie("username",username);
        Cookie ck2=new Cookie("password",password);

        getResponse().addCookie(ck1);
        getResponse().addCookie(ck2);

        getResponse().getWriter().write("Cookie添加完毕");
        return "redirect:/f1.jsp";
    }
}
